<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>订单评价</title>
    <link rel="stylesheet" href="/css/style.css">
</head>
<body>
<div class="container">
    <h1>订单评价</h1>
    <div style="margin-bottom:20px;">
        <b>订单编号：</b>${order.id} &nbsp;
        <b>菜品：</b>${order.dish.name} &nbsp;
        <b>下单时间：</b>${order.orderTime}
    </div>
    <form action="/comments/add" method="post" style="margin-bottom:30px;">
        <input type="hidden" name="orderId" value="${order.id}">
        <div class="form-group">
            <label for="content">评价内容：</label>
            <textarea id="content" name="content" required></textarea>
        </div>
        <div class="form-group">
            <label for="rating">评分：</label>
            <select id="rating" name="rating" required>
                <option value="5">5分</option>
                <option value="4">4分</option>
                <option value="3">3分</option>
                <option value="2">2分</option>
                <option value="1">1分</option>
            </select>
        </div>
        <button type="submit" class="order-btn">提交评价</button>
    </form>
    <h2>评价列表</h2>
    <c:forEach items="${comments}" var="comment">
        <div style="border:1px solid #eee;padding:15px;margin-bottom:15px;border-radius:6px;background:#fafafa;">
            <div><b>评分：</b>${comment.rating}分</div>
            <div><b>内容：</b>${comment.content}</div>
            <div><b>评价时间：</b>${comment.commentTime}</div>
            <c:if test="${not empty comment.reply}">
                <div style="margin-top:10px;color:#4CAF50;"><b>商家回复：</b>${comment.reply} <span style="font-size:0.9em;color:#888;">(${comment.replyTime})</span></div>
            </c:if>
            <c:if test="${empty comment.reply}">
                <form action="/comments/reply" method="post" style="margin-top:10px;">
                    <input type="hidden" name="commentId" value="${comment.id}">
                    <input type="text" name="reply" placeholder="商家回复..." required style="width:60%;">
                    <button type="submit" class="order-btn" style="padding:4px 10px;">回复</button>
                </form>
            </c:if>
        </div>
    </c:forEach>
    <div style="width:100%;background:#fff;box-shadow:0 2px 5px rgba(0,0,0,0.05);padding:16px 0 8px 0;display:flex;justify-content:flex-end;align-items:center;position:sticky;top:0;z-index:10;">
        <a href="/orders" class="order-btn" style="margin-right:20px;width:auto;padding:6px 18px;">返回订单</a>
        <a href="/logout" class="order-btn" style="margin-right:40px;width:auto;padding:6px 18px;background:#e44d26;">退出登录</a>
    </div>
</div>
</body>
</html> 